package com.dinzeer.sjapadder.entity;

import com.dinzeer.legendreliclib.lib.util.FastMakeEntityUtil;
import mods.flammpfeil.slashblade.entity.EntityDrive;
import mods.flammpfeil.slashblade.entity.Projectile;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.EntityHitResult;

public class DriveEntityLightning extends EntityDrive {
    public DriveEntityLightning(EntityType<? extends Projectile> entityTypeIn, Level worldIn) {
        super(entityTypeIn, worldIn);
    }

    @Override
    protected void onHitEntity(EntityHitResult entityHitResult) {
        super.onHitEntity(entityHitResult);
        if (entityHitResult.getEntity() instanceof LivingEntity lv) {
                if (this.getOwner() instanceof LivingEntity owner){
                    lv.invulnerableTime=0;
                 lv.hurt(FastMakeEntityUtil.DamageSourceToCreat(owner, DamageTypes.MAGIC), lv.getHealth()*0.04f);
                }
        }
    }
}
